//
//  SZLChargeMoneyViewController.m
//  Shengzhuli
//
//  Created by 卡忙科技 on 16/9/10.
//  Copyright © 2016年 kamangkeji. All rights reserved.
//

#import "SZLChargeMoneyViewController.h"
#import "SZLSinglePayViewController.h"
#import "MBProgressHUD+MJ.h"
#import "VefityTool.h"
#import "MyCountNetwork.h"
#import "SZLAccountHelper.h"

@interface SZLChargeMoneyViewController ()
@property (weak, nonatomic) IBOutlet UITextField *moneyField;

@end

@implementation SZLChargeMoneyViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"充值";
    self.view.backgroundColor = RGBColorOne(240);
}

- (IBAction)actionClick:(UIButton *)btn
{
    NSLog(@"%@",self.moneyField.text);
    if (self.moneyField.text.length<1) {
        [MBProgressHUD showError:@"请输入充值金额" toView:self.view];
        return;
    }
    if (![VefityTool isValidNumber:self.moneyField.text]) {
        [MBProgressHUD showError:@"请输入有效的金额数字" toView:self.view];
        return;
    }
    NSMutableDictionary *parame = [NSMutableDictionary dictionary];
    parame[@"token"] = [SZLAccountHelper shareInstance].token;
    parame[@"amount"] = self.moneyField.text;
    [self showWaiter];
    __WEAK
    [MyCountNetwork reChargeWithParame:parame response:^(BOOL success, NSString *msg, SingleCreateModel *model) {
        [self hideWaiter];
        if (success) {
            SZLSinglePayViewController *payVc = [[SZLSinglePayViewController alloc]init];
            payVc.payChargeType = PayChargeTypeCharge;
            payVc.model = model;
            [weakSelf.navigationController pushViewController:payVc animated:YES];
        }else{
            [MBProgressHUD showError:msg toView:self.view];
        }
    }];
}


@end
